package com.controller;

import org.springframework.web.bind.annotation.*;

@RestController
//@RequestMapping("/stu")
@RequestMapping(value = "/stu", produces = {"text/html;charset=UTF-8;", "application/json;"})
public class RestFulController {

    //根据id查询
    @GetMapping(value = "/{id}")
    public String findById(@PathVariable("id") Integer id){
        System.out.println("根据id查询："+id);
        return "根据id查询："+id;
    }

    //查询所有
    @GetMapping
    public String findAll(){
        System.out.println("查询所有");
        return "查询所有";
    }

    //分页查询学生
    @GetMapping("/{currentPage}/{pageSize}")
    public String findByPage(@PathVariable("currentPage") Integer currentPage,
                             @PathVariable("pageSize") Integer pageSize){
        System.out.println("分页查询学生信息");
        return "分页查询学生信息："+currentPage+pageSize;
    }

    //根据id新增
    @PostMapping("/{id}")
    public String addById(@PathVariable("id") Integer id){
        System.out.println("根据id新增："+id);
        return "根据id新增："+id;
    }

    //根据id删除
    @DeleteMapping("/{id}")
    public String deleteById(@PathVariable("id")Integer id){
        System.out.println("根据id删除："+id);
        return "根据id删除："+id;
    }

    //根据id修改
    @PutMapping("/{id}")
    public String updateById(@PathVariable("id")Integer id){
        System.out.println("根据id新增："+id);
        return "根据id新增："+id;
    }

}
